import request from '@/utils/request';
import { Employee, EmployeeType, MessageParams, PageEmp } from '@/type/employeeType';
import { ResponseType } from '@/type/ResponseType';

enum Enum {
  fetchEmployeeAPI = '/sys/user',
  deleteEmployeeAPI = 'sys/user',
  addEmployeeAPI = '/sys/user',
  findEmployeeAPI = '/sys/user',
  updateEmployeeAPI = '/sys/user',
  assignEmployeeRoleAPI = '/sys/user/assignRoles',
  sendMessageAPI = '/sys/messageMuch'
}

/**
 * @description 获取-员工列表的接口
 * */
export const fetchEmployeeAPI = async (params: PageEmp) => request.get<EmployeeType, ResponseType<EmployeeType>>(Enum.fetchEmployeeAPI, { params });

/**
 * @description 删除-员工的接口
 * */
export const deleteEmployeeAPI = (id: number) => request.delete<null, ResponseType<null>>(`${Enum.deleteEmployeeAPI}/${id}`);

/**
 * @description 新增-员工的接口
 * */
export const addEmployeeAPI = (data: Employee) => request.post<{ id: number }, ResponseType<{ id: number }>>(Enum.addEmployeeAPI, data);

/**
 * @description 获取-员工基本信息的接口
 * */
export const findEmployeeAPI = (id: number) => request.get<Employee, ResponseType<Employee>>(`${Enum.findEmployeeAPI}/${id}`);

/**
 * @description 修改-员工基本信息的接口
 * */
export const updateEmployeeAPI = (data: Employee) => request.put<{ id: string }, ResponseType<{ is: string }>>(`${Enum.updateEmployeeAPI}/${data.id}`, data);

/**
 * @description 分配员工角色的接口
 * */
export const assignEmployeeRoleAPI = (id: number, roleIds: number[]) => request.put<Employee, ResponseType<Employee>>(Enum.assignEmployeeRoleAPI, { id, roleIds });

/**
 * @description 群发通知的接口
 * */
export const sendMessageAPI = (data: MessageParams) => request.post<null, ResponseType<null>>(Enum.sendMessageAPI, data);
